﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.Threading;
using System.IO;

namespace Person_Mobile
{
    public class DS_NET_Client
    {
        PersonService.Service1Client client = new PersonService.Service1Client();
        List<PersonService.Person> pList = new List<PersonService.Person>();

        public List<PersonService.Person> Load()
        {
            client.LoadAsync();
            client.LoadCompleted += new EventHandler<PersonService.LoadCompletedEventArgs>(client_LoadCompleted);
                
            return pList;
        }

        public void Update(PersonService.Person p)
        {
            client.UpdateAsync(p);
        }

        public void Delete(int ID)
        {
            client.DeleteAsync(ID);
        }


        public void client_LoadCompleted(object sender, PersonService.LoadCompletedEventArgs e)
        {
            var list = e.Result;
            pList.Clear();
            foreach (PersonService.Person p in list)
            {
                pList.Add(p);
            }
        }

    }
}
